	// 定义一个 scale_fina2;

	for(k=1; k<=xmax; k++) {											// start after initial value

		x[k] = k-1;
		h = h_init;


		scale_fina = 1.0;
		// make attempts to minimize error
		for (j = 0; j < ATTEMPTS; j++) {//------------------

			error = 0;
			outside = 0;
			scale_min = MAX_SCALE_FACTOR;

			embedded_fehlberg_7_8(	x[k],h ,y[k-1],y[k],err,params,mode);

			for(i=0; i<EQUATIONS; i++){
				if(err[i] > 0){
					error = 1;
				}
			}
			if (error != 1) {
				scale_fina = MAX_SCALE_FACTOR; 
				break;
			}

			for(i=0; i<EQUATIONS; i++){
				if(y[k-1][i] == 0.0){
					yy[i] = tolerance;
				}
				else{
					yy[i] = fabs(y[k-1][i]);
				}
				scale[i] = 0.8 * pow( tolerance * yy[i] / err[i] , err_exponent );
				if(scale[i]<scale_min){
					scale_min = scale[i];
				}
			}
            // 修改这行：scale_fina = min( max(scale_min,MIN_SCALE_FACTOR), MAX_SCALE_FACTOR); 
			scale_fina2 = min( max(scale_min,MIN_SCALE_FACTOR), MAX_SCALE_FACTOR); 

			for(i=0; i<EQUATIONS; i++){
				if ( err[i] > ( tolerance * yy[i] ) ){
					outside = 1;
				}
			}
			if (outside == 0){
				break;
			}
             // 修改这行：h = h * scale_fina;
			if(scale_fina2 != scale_fina){scale_fina = scale_fina2; h = h * scale_fina;} 
             

			// limit step to 0.9, because when it gets close to 1, it no longer makes sense, as 1 is already the next time instance (added to original algorithm)
			if (h >= 0.9) {
				h = 0.9;
			}

			// if instance+step exceeds range limit, limit to that range
			if ( x[k] + h > (fp)xmax ){
				h = (fp)xmax - x[k];
			}

			// if getting closer to range limit, decrease step
			else if ( x[k] + h + 0.5 * h > (fp)xmax ){
				h = 0.5 * h;
			}

		}//---------------------
		x[k] = x[k] + h;
		if ( j >= ATTEMPTS ) {
			return -1; 
		}

	}
